package com.cmonbaby.adapter;

import com.cmonbaby.adapter.pattern.RViewCreate;

/**
 * 创建RViewHelper的工厂
 * @author simon 2016-11-03 上午11:05:29
 * @since JDK1.8 SDK6.0.1
 * @version V2.3.4
 */
public class RViewFactory {

    /**
     * 创建RecycleViewHelper实例，通过IRecycleViewHelperCreate实例和OnRecycleViewHelperListener实例来创建
     *
     * @param create RecycleView创建接口
     * @param listener Loding显示与隐藏接口
     * @return 下拉刷新和上拉加载的处理类
     */
    public static RViewHelper createRecycleViewHelper(RViewCreate create, RViewHelper.OnRecycleViewHelperListener listener) {
        return new RViewHelper.Builder()
                .swipeRefresh(create.createSwipeRefresh()) // 下拉刷新
                .colorRes(create.colorRes()) // 下拉颜色
                .recycleView(create.createRecyclerView()) // RecycleView
                .recycleViewAdapter(create.createRecycleViewAdapter()) // RecycleViewAdapter
                .layoutManager(create.createLayoutManager()) // 布局样式，如瀑布流
                .itemDecoration(create.createItemDecoration()) // 列表分割线
                .emptyView(create.createEmptyView()) // 空布局
                .loadMoreView(create.createLoadMoreView()) // 加载更多
                .startPageNumber(create.startPageNumber()) // 开始页码
                .rowsPageNumber(create.rowsPageNumber()) // 最后一页少于多少条数据显示无更多数据
                .isSupportPaging(create.isSupportPaging()) // 支持分页
                .recycleViewHelperListener(listener) // 对话框监听
                .build();
    }
}
